import tinymce from 'tinymce/tinymce'
import { checkBeforeInsert, emit } from '@/utils/helpers'

tinymce.PluginManager.add('department', function (editor) {
  editor.ui.registry.addMenuItem('department', {
    text: '组织单位',
    onAction: function () {
      if (!checkBeforeInsert('department')) return
      emit('show-dept-dialog')
    }
  })

  return {
    getMetadata: function () {
      return {
        name: '组织单位',
        url: 'http://sfrj.cn'
      }
    }
  }
})
